<script type="text/javascript" >
    stFacebookToolbox.load_tooltip();
    stFacebookToolbox.on_submitform('#settingForm');
    jQuery(document).ready(function() {
        jQuery('#inner_content').css('width','100%');
        jQuery('#inner_content').css('float','left');
        jQuery('#side-nav').fadeOut('normal');
        //jQuery("a[action='gallery_app']").remove();
        //jQuery("a[action='coupon']").remove();
        var array = jQuery("a[action='gallery_app']");
        array[0].innerHTML = '';
        var array = jQuery("a[action='coupon']");
        array[0].innerHTML = '';
        jQuery( "#fan_growth" ).draggable({revert:true});
        jQuery( "#most_like_link" ).draggable({revert:true});
        jQuery( "#website_viral_spread" ).draggable({revert:true});
        jQuery( "#form_builder_stats" ).draggable({revert:true});
        jQuery( "#postcard_stats").draggable({revert:true});
        jQuery( "#droppable" ).droppable({
            hoverClass: 'dropareahover',
            tolerance: 'pointer',
            opacity: 0.6,
            cursor: 'move',
            drop: function( event, ui ) {
                if(ui.draggable.attr('id') == 'fan_growth')
                {
                    id = '1';
                }
                else
                {
                    if(ui.draggable.attr('id') == 'most_like_link')
                    {
                        id = '2';
                    }
                    else
                    {
                       if(ui.draggable.attr('id') == 'website_viral_spread'){
                           id = '3';
                       }
                       else {
                           if(ui.draggable.attr('id') == 'form_builder_stats'){
                               id = '4';
                           }
                           else {
                               id = '5';
                           }
                       }
                    }
                }
                data_post = new Array();
                data_post['delete'] = 'true';
                data_post['id'] = id;
                jQuery( "#dialog-confirm" ).html("Are you sure to delete this box ?");
                jQuery( "#dialog-confirm" ).dialog({
                    title: 'Confirm',
                    resizable: false,
                    modal: true,
                    show: "slide",
                    hide: "slide",
                    buttons: [
                        {
                            text: "Delete",
                            click: function() {
                                jQuery( this ).dialog( "close" );
                                stFacebookToolbox.loadPage('dashboard',data_post,null,function(){
                                    stFacebookToolbox.loadPage("dashboard");
                                });

                            }
                        },
                        {
                            text: "Cancel",
                            click: function() {
                                jQuery( this ).dialog( "close" );
                            }
                        }
                    ]
                });
            }
        });
    });

</script>
<div class="w100p bgl">
    <div class="w100p bgr p5b">
        <center>
            <ul class="list_dashboard">
                <?php
                if(count($option['facebook_dashboard']) > 0)
                {
                 foreach ($option['facebook_dashboard'] as $row) {
                    $model->echo_dashboard(intval($row));
               	 }
                }
                ?>



            </ul>

        </center>
        <div id="droppable" class="ui-droppable"></div>
        <br clear='both'>

    </div>
</div>
<div id="display_add_dashboard" style="display:none;">
    <p style="padding-top:10px;">
        Select box to add:&nbsp;
        <select name="box" id="box" onchange="jQuery('#box_dashboard').val(this.value);">
            <?php if (!in_array('1', $option['facebook_dashboard'])) {
 ?><option value="1">Fan Growth</option><?php } ?>
<?php if (!in_array('2', $option['facebook_dashboard'])) { ?><option value="2">Most liked link</option><?php } ?>
<?php if (!in_array('3', $option['facebook_dashboard'])) { ?><option value="3">Viral Spread</option> <?php } ?>
<?php if (!in_array('4', $option['facebook_dashboard']) AND $functions->appPermission($config, 'applications')) { ?><option value="4">Form builder stats</option> <?php } ?>
<?php if (!in_array('5', $option['facebook_dashboard']) AND $functions->appPermission($config, 'appPostcard')) { ?><option value="5">Postcard stats</option> <?php } ?>
        </select>
        
    </p>
</div>
<input type="hidden" id="box_dashboard" />
